package com.niit.configurer;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

@Configuration
public class WebMvcConfigurer implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/**").addResourceLocations("classpath:/images/");
        registry.addResourceHandler("/css/**").addResourceLocations("classpath:/css/");
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
        registry.addResourceHandler("/fonts/**").addResourceLocations("classpath:/fonts/");
        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");


        //上传的图片在F盘下的uploads目录下，
        // 访问路径如：http://localhost:8080/images/2021-05-31/d06a63fd-7245-4dc5-9acc-dc5e001af45e.jpg
        //其中images表示访问的前缀。"file:F:/uploads/"是文件真实的存储路径
//        registry.addResourceHandler("/images/**").addResourceLocations("file:F:/uploads/");


    }
}
